// Copyright 2013 Square, Inc.
package org.assertj.ohos.api.widget;

import ohos.agp.components.Switch;
import ohos.agp.components.element.Element;
import ohos.global.resource.NotExistException;
import ohos.global.resource.WrongTypeException;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;

public class SwitchAssert extends AbstractCompoundButtonAssert<SwitchAssert, Switch> {
  public SwitchAssert(Switch actual) {
    super(actual, SwitchAssert.class);
  }
/* // TODO: wang, not found in ohos
  public SwitchAssert hasSwitchMinWidth(int width) {
    isNotNull();
    int actualWidth = actual.getSwitchMinWidth();
    assertThat(actualWidth) //
        .overridingErrorMessage("Expected switch min width <%s> but was <%s>.", width,
            actualWidth) //
        .isEqualTo(width);
    return this;
  }

  public SwitchAssert hasSwitchPadding(int padding) {
    isNotNull();
    int actualPadding = actual.getSwitchPadding();
    assertThat(actualPadding) //
        .overridingErrorMessage("Expected switch padding <%s> but was <%s>.", padding,
            actualPadding) //
        .isEqualTo(padding);
    return this;
  }*/

  public SwitchAssert hasOnText(CharSequence text) {
    isNotNull();
    CharSequence actualText = actual.getStateOnText();
    assertThat(actualText) //
        .overridingErrorMessage("Expected 'on' text <%s> but was <%s>.", text, actualText) //
        .isEqualTo(text);
    return this;
  }

  public SwitchAssert hasOnText(int resId) throws NotExistException, WrongTypeException, IOException {
    isNotNull();
    String text = actual.getContext().getResourceManager().getElement(resId).getString();
    return hasOnText(text);
  }

  public SwitchAssert hasOffText(CharSequence text) {
    isNotNull();
    CharSequence actualText = actual.getStateOffText();
    assertThat(actualText) //
        .overridingErrorMessage("Expected 'off' text <%s> but was <%s>.", text, actualText) //
        .isEqualTo(text);
    return this;
  }

  public SwitchAssert hasOffText(int resId) throws NotExistException, WrongTypeException, IOException {
    isNotNull();
    String text = actual.getContext().getResourceManager().getElement(resId).getString();
    return hasOffText(text);
  }

  public SwitchAssert hasThumbDrawable(Element drawable) {
    isNotNull();
    Element actualDrawable = actual.getThumbElement();
    assertThat(actualDrawable) //
        .overridingErrorMessage("Expected thumb drawable <%s> but was <%s>.", drawable,
            actualDrawable) //
        .isSameAs(drawable);
    return this;
  }
/* // TODO: wang, not found in ohos
  public SwitchAssert hasThumbTextPadding(int padding) {
    isNotNull();
    int actualPadding = actual.getThumbTextPadding();
    assertThat(actualPadding) //
        .overridingErrorMessage("Expected thumb text padding <%s> but was <%s>.", padding,
            actualPadding) //
        .isEqualTo(padding);
    return this;
  }*/

  public SwitchAssert hasTrackDrawable(Element drawable) {
    isNotNull();
    Element actualDrawable = actual.getTrackElement();
    assertThat(actualDrawable) //
        .overridingErrorMessage("Expected track drawable <%s> but was <%s>.", drawable,
            actualDrawable) //
        .isSameAs(drawable);
    return this;
  }
}
